package week07.day02;

/**
 * 1、创建父类--动物类Animal
 * 2、创建子类--猫类Cat、狗类Dog
 * 3、创建子类对象测试继承后的属性和方法
 */

public class 继承练习 {
    public static void main(String[] args) {
        Animal animal = new Animal();
        Cat Cat = new Cat();
        Dog Dog = new Dog();
        Cat.setFoot("四只脚");
        Cat.getFoot();
        Cat.setWalking("爬行");
        Cat.getWalking();
        Dog.setFoot("四只脚");
        Dog.getFoot();
        Dog.setWalking("爬行");
        Dog.getWalking();
        Cat.name = "Tom";
        Dog.name = "Spake";
        System.out.println(Cat.name+Cat.getFoot()+Cat.getWalking());
        System.out.println(Dog.name+Dog.getFoot()+Dog.getWalking());
        mouse mouse = new mouse();
        mouse.name = "Jerry";
        mouse.setFoot("四只脚");
        mouse.setWalking("爬行");
        mouse.getFoot();
        mouse.getWalking();
        System.out.println(mouse.name+mouse.getFoot()+mouse.getWalking());
    }
}

//父类
class Animal{
    private String foot;
    private String walking;
    public void eat(){
        System.out.println("动物都要吃东西");
    }

    public String getFoot() {
        return foot;
    }

    public void setFoot(String foot) {
        this.foot = foot;
    }

    public String getWalking() {
        return walking;
    }

    public void setWalking(String walking) {
        this.walking = walking;
    }
}

class Cat extends Animal{
    String name;

}

class Dog extends Animal{
    String name;
}

class mouse extends Dog{}
